package com.zzx.project.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName: GlobalWebMvcConfigurer
 * @Description: 全局mvc配置类
 * @Author zhouzhixin
 * @Date 2021/5/8
 * @Version 1.0
 */
@Component
public class GlobalWebMvcConfigurer implements WebMvcConfigurer {

    private TraceIdInterceptor traceIdInterceptor;

    @Autowired
    private void setTraceIdInterceptor(TraceIdInterceptor traceIdInterceptor) {
        this.traceIdInterceptor = traceIdInterceptor;
    }

    /**
     * traceId 拦截器需要在最开始执行
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(traceIdInterceptor).order(0);
    }

}
